package com.bootx.controller.api;

import com.bootx.common.Result;
import com.bootx.controller.BaseController;
import com.bootx.entity.BaseEntity;
import com.bootx.entity.BetInfo;
import com.bootx.entity.Lottery;
import com.bootx.service.BetInfoService;
import com.bootx.service.LotteryService;
import com.fasterxml.jackson.annotation.JsonView;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author black
 */
@RestController
@RequestMapping("/api/betInfo")
public class BetInfoController extends BaseController {

    @Resource
    private BetInfoService betInfoService;

    @PostMapping("/edit")
    @JsonView(BaseEntity.EditView.class)
    public Result edit(){
        return Result.success(betInfoService.find(1L));
    }

    @PostMapping("/save")
    @JsonView(BaseEntity.EditView.class)
    public Result save(BetInfo betInfo,Boolean clean){
        BetInfo old = betInfoService.find(betInfo.getId());
        old.setNum(betInfo.getNum());
        old.setType(betInfo.getType());
        old.setMoney(betInfo.getMoney());
        old.setOpen(betInfo.getOpen());
        betInfoService.update(old);
        jdbcTemplate.update("truncate betrecord;");
        return Result.success();
    }

}
